{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "********************\n",
      "********************\n",
      "loading_jupyter_server_extension: jupyter-text2code. First install will download universal-sentence-encoder, please wait...\n",
      "********************\n",
      "********************\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "sys.path.insert(0,'../')\n",
    "from jupyter_text2code.jupyter_text2code_serverextension import CodeGenerator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "cg = CodeGenerator()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent 1 : import x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'import spacy'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"import spacy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'import pandas'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"import pandas\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent2:  import all libs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "import pandas as pd\n",
      "import numpy as np\n",
      "import os\n",
      "import plotly.express as px\n",
      "import matplotlib.pyplot as plt\n",
      "pd.options.plotting.backend = 'plotly'\n",
      "        \n"
     ]
    }
   ],
   "source": [
    "print(cg.generate_code(\"import all libraries\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent3: install lib"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'!pip install matplotlib'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"install matplotlib\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'!pip install scikitlearn'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"install scikitlearn\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent4: Load file into df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"xxx = pd.read_csv('train.csv')\""
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"load train.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Load file into a dataframe  Intent_id: 2  Similarity 0.88224137\n",
      "Entities:\n",
      "train.csv 5 14 FNAME\n",
      "zzzz 18 22 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"zzzz = pd.read_csv('train.csv')\""
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"load train.csv in zzzz\", debug=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent5: Show x rows from df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Show x rows from df  Intent_id: 3  Similarity 0.7455359\n",
      "Entities:\n",
      "df 10 12 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'df.head()'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Show from df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"#Couldn't extract variable name, replacing with default\\nxxx.head()\""
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Show alldf\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Show x rows from df  Intent_id: 3  Similarity 1.0\n",
      "Entities:\n",
      "5 5 6 CARDINAL\n",
      "df 17 19 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'df.head(5)'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Show 5 rows from df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'df.head(20)'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Show 20 rows of df\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent6: List columns of df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'mydf.columns'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"list all columns of mydf\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent7: Describe the df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'df.describe()'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Describe df\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'mydf.describe()'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Describe mydf\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent8: Plot histogram of column"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: histogram of column  Intent_id: 4  Similarity 0.9223975\n",
      "Entities:\n",
      "rainfall 18 26 COLNAME\n",
      "df 37 39 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'df.plot.hist(x=[\"rainfall\"])'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Plot histogram of rainfall column in df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: histogram of column  Intent_id: 4  Similarity 0.9799768\n",
      "Entities:\n",
      "xzcx 18 22 COLNAME\n",
      "df 33 35 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'df.plot.hist(x=[\"xzcx\"])'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Plot histogram of xzcx column in df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: histogram of column  Intent_id: 4  Similarity 0.91642696\n",
      "Entities:\n",
      "age 18 21 VARNAME\n",
      "df 25 27 VARNAME\n",
      "----------\n",
      "Error:  Didn't detect the column name\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'#Couldn\\'t extract column names, replacing with default\\nage.plot.hist(x=[\"xxx\", \"yyy\"])'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Plot histogram of age in df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: histogram of column  Intent_id: 4  Similarity 0.98263717\n",
      "Entities:\n",
      "dailywage 18 27 COLNAME\n",
      "df 38 40 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'df.plot.hist(x=[\"dailywage\"])'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Plot histogram of dailyWage column in df\", debug=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent9: Get correlation matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'df.corr()'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Get correlation matrix of df\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent10: Print shape of df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'df.shape'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Print shape of df\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'zz.shape'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Print shape of zz\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent11: Barplot two columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Bar of column1 and column2 from df  Intent_id: 7  Similarity 0.7900896\n",
      "Entities:\n",
      "duration 9 17 COLNAME\n",
      "age 22 25 COLNAME\n",
      "df 31 33 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"px.bar(x='duration',y='age',data_frame=df,title='CustomTitle', labels={'duration':'duration','age':'age'})\""
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Bar plot duration and age from df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Bar of column1 and column2 from df  Intent_id: 7  Similarity 0.8381791\n",
      "Entities:\n",
      "age 9 12 COLNAME\n",
      "temperature 17 28 COLNAME\n",
      "df 42 44 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"px.bar(x='age',y='temperature',data_frame=df,title='CustomTitle', labels={'age':'age','temperature':'temperature'})\""
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Bar plot age and temperature columns from df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Bar of column1 and column2 from df  Intent_id: 7  Similarity 0.8020855\n",
      "Entities:\n",
      "temperature 9 20 COLNAME\n",
      "humidity 25 33 COLNAME\n",
      "df 45 47 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"px.bar(x='temperature',y='humidity',data_frame=df,title='CustomTitle', labels={'temperature':'temperature','humidity':'humidity'})\""
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Bar plot temperature and humidity columns of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Bar of column1 and column2 from df  Intent_id: 7  Similarity 0.9778261\n",
      "Entities:\n",
      "numitems 21 29 COLNAME\n",
      "purchasemonth 44 57 COLNAME\n",
      "df 71 73 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"px.bar(x='numitems',y='purchasemonth',data_frame=df,title='CustomTitle', labels={'numitems':'numitems','purchasemonth':'purchasemonth'})\""
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"show a bar plot with numItems on x axis and purchaseMonth on y axis in df\", debug=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent12: Pie chart of a column in df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Pie chart of column in   Intent_id: 8  Similarity 0.8810677\n",
      "Entities:\n",
      "age 12 15 COLNAME\n",
      "df 26 28 VARNAME\n",
      "gender 40 46 COLNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"tmp = df['age'].value_counts(dropna=False)\\npx.pie(tmp,values=tmp.values,names=tmp.index,title='CustomTitle')\""
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"piechart of age column in df grouped by gender column\", debug=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Intent13: Group df "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: group the df by column1 and get average of column2  Intent_id: 12  Similarity 0.7937273\n",
      "Entities:\n",
      "df 10 12 VARNAME\n",
      "gender 16 22 COLNAME\n",
      "average 31 38 FUNCTION\n",
      "age 42 45 VARNAME\n",
      "----------\n",
      "Use mean for synonym average\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df.groupby(['gender']).agg(['mean'])\""
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Group the df by gender and get average of age\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: group the df by column1 and get average of column2  Intent_id: 12  Similarity 0.79380095\n",
      "Entities:\n",
      "df 6 8 VARNAME\n",
      "gender 12 18 COLNAME\n",
      "mean 27 31 FUNCTION\n",
      "age 35 38 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df.groupby(['gender']).agg(['mean'])\""
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Group df by gender and get mean of age\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: group the df by column1 and get average of column2  Intent_id: 12  Similarity 0.77789533\n",
      "Entities:\n",
      "df 6 8 VARNAME\n",
      "gender 12 18 COLNAME\n",
      "mean 27 31 FUNCTION\n",
      "sum 36 39 FUNCTION\n",
      "age 43 46 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df.groupby(['gender']).agg(['mean','sum'])\""
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Group df by gender and get mean and sum of age\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: group the df by column1 and get average of column2  Intent_id: 12  Similarity 0.7954531\n",
      "Entities:\n",
      "df 6 8 VARNAME\n",
      "gender 12 18 COLNAME\n",
      "average 27 34 FUNCTION\n",
      "sum 36 39 FUNCTION\n",
      "age 43 46 VARNAME\n",
      "----------\n",
      "Use mean for synonym average\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df.groupby(['gender']).agg(['mean','sum'])\""
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Group df by gender and get average, sum of age\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: group the df by column1 and get average of column2  Intent_id: 12  Similarity 0.81393397\n",
      "Entities:\n",
      "df 6 8 VARNAME\n",
      "ozxc 12 16 COLNAME\n",
      "zxc 18 21 COLNAME\n",
      "min 30 33 FUNCTION\n",
      "max 35 38 FUNCTION\n",
      "sum 40 43 FUNCTION\n",
      "corr 47 51 COLNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df[['ozxc','zxc','corr']].groupby(['ozxc','zxc']).agg(['min','max','sum'])\""
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Group df by ozxc, zxc and get min, max, sum of corr\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: group the df by column1 and get average of column2  Intent_id: 12  Similarity 0.6917082\n",
      "Entities:\n",
      "df 10 12 VARNAME\n",
      "gender 16 22 COLNAME\n",
      "average 31 38 FUNCTION\n",
      "age 39 42 FUNCTION\n",
      "----------\n",
      "Use mean for synonym average\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df.groupby(['gender']).agg(['mean','age'])\""
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"Group the df by gender and get average age\", debug=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: install lib  Intent_id: 9  Similarity 0.99999994\n",
      "Entities:\n",
      "plotly 8 14 LIBNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'!pip install plotly'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"install plotly\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Pie chart of column in   Intent_id: 8  Similarity 0.8031008\n",
      "Entities:\n",
      "heroes_gender 18 31 COLNAME\n",
      "df 35 37 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"tmp = df['heroes_gender'].value_counts(dropna=False)\\npx.pie(tmp,values=tmp.values,names=tmp.index,title='CustomTitle')\""
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"plot pie chart of heroes_gender in df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: histogram of column  Intent_id: 4  Similarity 0.8690444\n",
      "Entities:\n",
      "heroes_gender 18 31 COLNAME\n",
      "youtube_views 36 49 COLNAME\n",
      "df 61 63 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'df.plot.hist(x=[\"heroes_gender\", \"youtube_views\"])'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"plot histogram of heroes_gender and youtube_views columns of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: histogram of column  Intent_id: 4  Similarity 0.8805045\n",
      "Entities:\n",
      "heroes_gendes 18 31 COLNAME\n",
      "zxc 36 39 COLNAME\n",
      "df 51 53 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'df.plot.hist(x=[\"heroes_gendes\", \"zxc\"])'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"plot histogram of heroes_gendes and zxc columns of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: line chart of column1 and column2 of df  Intent_id: 13  Similarity 0.88551736\n",
      "Entities:\n",
      "release_date 10 22 COLNAME\n",
      "youtube_avg_watch_duration 27 53 COLNAME\n",
      "df 57 59 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df.plot.line(x='release_date', y='youtube_avg_watch_duration', color=None, title='CustomTitle', labels={'release_date':'release_date', 'youtube_avg_watch_duration':'youtube_avg_watch_duration'})\""
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"line plot release_date and youtube_avg_watch_duration of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: scatter plot of column1 and column2 of df  Intent_id: 14  Similarity 0.90176094\n",
      "Entities:\n",
      "spotify_streams 16 31 COLNAME\n",
      "youtube_views 36 49 COLNAME\n",
      "df 53 55 VARNAME\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"df.plot.scatter(x='spotify_streams', y='youtube_views', color=None, size=None, title='CustomTitle', labels={'spotify_streams':'spotify_streams', 'youtube_views':'youtube_views'})\""
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"scatter plot of spotify_streams and youtube_views of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: Bar of column1 and column2 from df  Intent_id: 7  Similarity 0.84774184\n",
      "Entities:\n",
      "release_date 18 30 COLNAME\n",
      "df 63 65 VARNAME\n",
      "----------\n",
      "Error:  Didn't detect the column name\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"#Couldn't extract column names, replacing with default\\npx.bar(x='xxx',y='yyy',data_frame=df,title='CustomTitle', labels={'xxx':'xxx','yyy':'yyy'})\""
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"plot line plot of release_date & youtube_avg_watch_duration of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: line chart of column1 and column2 of df  Intent_id: 13  Similarity 0.83657575\n",
      "Entities:\n",
      "release_date 13 25 COLNAME\n",
      "df 58 60 VARNAME\n",
      "----------\n",
      "Error:  Didn't detect the column name\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"#Couldn't extract column names, replacing with default\\ndf.plot.line(x='xxx', y='yyy', color=None, title='CustomTitle', labels={'xxx':'xxx', 'yyy':'yyy'})\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"line plot of release_date & youtube_avg_watch_duration of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: line chart of column1 and column2 of df  Intent_id: 13  Similarity 0.84694755\n",
      "Entities:\n",
      "release_date 20 32 COLNAME\n",
      "df 65 67 VARNAME\n",
      "----------\n",
      "Error:  Didn't detect the column name\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"#Couldn't extract column names, replacing with default\\ndf.plot.line(x='xxx', y='yyy', color=None, title='CustomTitle', labels={'xxx':'xxx', 'yyy':'yyy'})\""
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"show a line plot of release_date & youtube_avg_watch_duration of df\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: line chart of column1 and column2 of df  Intent_id: 13  Similarity 0.8588614\n",
      "Entities:\n",
      "release_date 5 17 CARDINAL\n",
      "df 50 52 VARNAME\n",
      "----------\n",
      "Error:  Didn't detect the column name\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"#Couldn't extract column names, replacing with default\\ndf.plot.line(x='xxx', y='yyy', color=None, title='CustomTitle', labels={'xxx':'xxx', 'yyy':'yyy'})\""
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"show release_date & youtube_avg_watch_duration of df in a line plot\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: barplot $colname and $colname columns of $varname  Intent_id: 7  Similarity 0.89604545\n",
      "Entities:\n",
      "release_date 5 17 CARDINAL\n",
      "df 50 52 VARNAME\n",
      "----------\n",
      "Error:  Didn't detect the column name\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"#Couldn't extract column names, replacing with default\\npx.bar(x='xxx',y='yyy',data_frame=df,title='CustomTitle', labels={'xxx':'xxx','yyy':'yyy'})\""
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"show release_date & youtube_avg_watch_duration of df in a bar plot\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: barplot $colname and $colname columns of $varname  Intent_id: 7  Similarity 0.8960455\n",
      "Entities:\n",
      "release_date 5 17 CARDINAL\n",
      "df 50 52 VARNAME\n",
      "----------\n",
      "Error:  Didn't detect the column name\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"#Couldn't extract column names, replacing with default\\npx.bar(x='xxx',y='yyy',data_frame=df,title='CustomTitle', labels={'xxx':'xxx','yyy':'yyy'})\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"show release_date & youtube_avg_watch_duration of df in a bar plot\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Intent: switch to dark theme  Intent_id: 17  Similarity 0.9999999\n",
      "Entities:\n",
      "----------\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\"import plotly.io as pio\\npio.templates.default = 'plotly_dark'\""
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cg.generate_code(\"switch to dark theme\", debug=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
